package com.github.linkoog.model_designer.ide.action;

import com.github.linkoog.model_designer.Icons;
import com.intellij.ide.actions.CreateFileFromTemplateAction;
import com.intellij.ide.actions.CreateFileFromTemplateDialog;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDirectory;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;

public class NewDBTableAction extends CreateFileFromTemplateAction implements DumbAware {

    private static final String DEFAULT_DBMODEL_TEMPLATE_PROPERTY = "DefaultDBTableFileTemplate";

    public NewDBTableAction() {
        super("DBTable File", "Creates new DBTable file", Icons.MODEL);
    }

    @Override
    protected String getDefaultTemplateProperty() {
        return DEFAULT_DBMODEL_TEMPLATE_PROPERTY;
    }

    @Override
    protected void buildDialog(@NotNull Project project, @NotNull PsiDirectory directory, @NotNull CreateFileFromTemplateDialog.Builder builder) {
        builder
            .setTitle("New DBTable File")
            .addKind("Empty DBTable", Icons.MODEL, "Empty Table File")
            .addKind("General DBTable", Icons.MODEL, "General Table File");
    }

    @Override
    protected String getActionName(PsiDirectory directory, @NotNull String newName, @NonNls String templateName) {
        return "DBTable File";
    }

    @Override
    public int hashCode() {
        return 0;
    }

    @Override
    public boolean equals(Object obj) {
        return obj instanceof NewDBTableAction;
    }
}
